import React, { Component } from 'react'

export default class FormDemo1 extends Component {
  constructor(){
    super()
    this.userNameRef=React.createRef()
    this.passwordRef=React.createRef()
  }
  login=(e)=>{
    e.preventDefault()
    console.log('姓名:',this.userNameRef.current.value);
  }
  render() {
    return (
      <div>
        <form action="http://www.zhaijizhe.cn" onSubmit={this.login}>
            <div>
                <label htmlFor="userName">姓名:</label>
                <input type="text" id='userName' ref={this.userNameRef}/>
            </div>
            <div>
                <label htmlFor="password">密码:</label>
                <input type="text" id='password' ref={this.passwordRef}/>
            </div>
            <div>
                <input type='submit' value={"提交"}></input>
            </div>
        </form>
      </div>
    )
  }
}
